package com.ftg.learn.springboot.demo.mapper;

import com.ftg.learn.springboot.demo.pojo.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface StudentMapper {

	@Select("select * from student")
	List<Student> list();

	@Select("select * from student where sno = ifnull(#{arg2},sno) or sname like ifnull(concat(#{arg2},'%'),sname) limit #{arg0},#{arg1}")
	List<Student> showAll(int begin, int limit, String deptno);

	@Select("select count(*) from student where sno = ifnull(#{arg0},sno) or sname like ifnull(concat(#{arg0},'%'),sname) ")
	int getCount(String deptno);

	@Delete("delete from student where sno = #{sno}")
	int del(int id);

	@Update("update student set sname=#{sname}, sage=#{sage}, ssex=#{ssex} where sno=#{sno}")
	int update(Student student);

	@Insert("insert into student(sno,sname,sage,ssex) values(#{sno},#{sname},#{sage},#{ssex})")
	int add(Student student);
}
